import { IPSControlAttribute } from '../ipscontrol-attribute';
import { IPSControlLogic } from '../ipscontrol-logic';
import { IPSControlRender } from '../ipscontrol-render';
import { IPSDEFDCatGroupLogic } from './ipsdefdcat-group-logic';
import { IPSDEFormDetail } from './ipsdeform-detail';
import { IPSLayout } from '../layout/ipslayout';
import { IPSLayoutItem } from '../layout/ipslayout-item';
import { IPSLayoutPos } from '../layout/ipslayout-pos';
import { IPSLanguageRes } from '../../res/ipslanguage-res';
import { IPSSysCss } from '../../res/ipssys-css';
import { IPSSysImage } from '../../res/ipssys-image';
import { IPSSysPFPlugin } from '../../res/ipssys-pfplugin';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSDEFormDetailImpl extends PSModelObjectImpl implements IPSDEFormDetail, IPSLayoutItem {
  protected cappslanguageres: IPSLanguageRes | null = null;

  getCapPSLanguageRes(): IPSLanguageRes | null {
    if (this.cappslanguageres != null) return this.cappslanguageres;
    const value = this.M.getCapPSLanguageRes;
    if (value == null) {
      return null;
    }
    this.cappslanguageres = this.getPSModel4('res.IPSLanguageRes', value, 'getCapPSLanguageRes') as IPSLanguageRes;
    return this.cappslanguageres;
  }

  get capPSLanguageRes(): IPSLanguageRes | null {
    return this.getCapPSLanguageRes();
  }

  getCapPSLanguageResMust(): IPSLanguageRes {
    const value = this.getCapPSLanguageRes();
    if (value == null) {
      throw new Error('未指定标题语言资源');
    }
    return value;
  }

  get caption(): string {
    return this.M.caption;
  }

  get codeName(): string {
    return this.M.codeName;
  }

  get columnAlign(): 'LEFT' | 'CENTER' | 'RIGHT' {
    return this.M.columnAlign;
  }

  get contentHeight(): number {
    return this.M.contentHeight != null ? this.M.contentHeight : 0.0;
  }

  get contentWidth(): number {
    return this.M.contentWidth != null ? this.M.contentWidth : 0.0;
  }

  get cssStyle(): string {
    return this.M.cssStyle;
  }

  get detailStyle(): 'DEFAULT' | 'STYLE2' | 'STYLE3' | 'STYLE4' {
    return this.M.detailStyle;
  }

  get detailType(): 'FORMPAGE' | 'TABPANEL' | 'TABPAGE' | 'FORMITEM' | 'USERCONTROL' | 'FORMPART' | 'GROUPPANEL' | 'DRUIPART' | 'RAWITEM' | 'BUTTON' | 'IFRAME' | 'FORMITEMEX' | 'MDCTRL' {
    return this.M.detailType;
  }

  get dynaClass(): string {
    return this.M.dynaClass;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get height(): number {
    return this.M.height != null ? this.M.height : 0.0;
  }

  get labelCssStyle(): string {
    return this.M.labelCssStyle;
  }

  get labelDynaClass(): string {
    return this.M.labelDynaClass;
  }

  protected labelpssyscss: IPSSysCss | null = null;

  getLabelPSSysCss(): IPSSysCss | null {
    if (this.labelpssyscss != null) return this.labelpssyscss;
    const value = this.M.getLabelPSSysCss;
    if (value == null) {
      return null;
    }
    this.labelpssyscss = this.getPSModel4('res.IPSSysCss', value, 'getLabelPSSysCss') as IPSSysCss;
    return this.labelpssyscss;
  }

  get labelPSSysCss(): IPSSysCss | null {
    return this.getLabelPSSysCss();
  }

  getLabelPSSysCssMust(): IPSSysCss {
    const value = this.getLabelPSSysCss();
    if (value == null) {
      throw new Error('未指定成员标签样式表');
    }
    return value;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected pscontrolattributes: IPSControlAttribute[] | null = null;

  getPSControlAttributes(): IPSControlAttribute[] | null {
    if (this.pscontrolattributes == null) {
      this.pscontrolattributes = this.fillChildListModel(this.M.getPSControlAttributes, 'control.IPSControlAttribute') as IPSControlAttribute[];
    }
    return this.pscontrolattributes;
  }

  get psControlAttributes(): IPSControlAttribute[] | null {
    return this.getPSControlAttributes();
  }

  findPSControlAttribute(objKey: any): IPSControlAttribute | null {
    return this.getPSModel5('control.IPSControlAttribute', this.getPSControlAttributes(), objKey) as IPSControlAttribute;
  }

  protected pscontrollogics: IPSControlLogic[] | null = null;

  getPSControlLogics(): IPSControlLogic[] | null {
    if (this.pscontrollogics == null) {
      this.pscontrollogics = this.fillChildListModel(this.M.getPSControlLogics, 'control.IPSControlLogic') as IPSControlLogic[];
    }
    return this.pscontrollogics;
  }

  get psControlLogics(): IPSControlLogic[] | null {
    return this.getPSControlLogics();
  }

  findPSControlLogic(objKey: any): IPSControlLogic | null {
    return this.getPSModel5('control.IPSControlLogic', this.getPSControlLogics(), objKey) as IPSControlLogic;
  }

  protected pscontrolrenders: IPSControlRender[] | null = null;

  getPSControlRenders(): IPSControlRender[] | null {
    if (this.pscontrolrenders == null) {
      this.pscontrolrenders = this.fillChildListModel(this.M.getPSControlRenders, 'control.IPSControlRender') as IPSControlRender[];
    }
    return this.pscontrolrenders;
  }

  get psControlRenders(): IPSControlRender[] | null {
    return this.getPSControlRenders();
  }

  findPSControlRender(objKey: any): IPSControlRender | null {
    return this.getPSModel5('control.IPSControlRender', this.getPSControlRenders(), objKey) as IPSControlRender;
  }

  protected psdefdgrouplogics: IPSDEFDCatGroupLogic[] | null = null;

  getPSDEFDGroupLogics(): IPSDEFDCatGroupLogic[] | null {
    if (this.psdefdgrouplogics == null) {
      this.psdefdgrouplogics = this.fillChildListModel(this.M.getPSDEFDGroupLogics, 'control.form.IPSDEFDCatGroupLogic') as IPSDEFDCatGroupLogic[];
    }
    return this.psdefdgrouplogics;
  }

  get psDEFDGroupLogics(): IPSDEFDCatGroupLogic[] | null {
    return this.getPSDEFDGroupLogics();
  }

  findPSDEFDCatGroupLogic(objKey: any): IPSDEFDCatGroupLogic | null {
    return this.getPSModel5('control.form.IPSDEFDCatGroupLogic', this.getPSDEFDGroupLogics(), objKey) as IPSDEFDCatGroupLogic;
  }

  protected pslayout: IPSLayout | null = null;

  getPSLayout(): IPSLayout | null {
    if (this.pslayout != null) return this.pslayout;
    const value = this.M.getPSLayout;
    if (value == null) {
      return null;
    }
    this.pslayout = this.getPSModel4('control.layout.IPSLayout', value, 'getPSLayout') as IPSLayout;
    return this.pslayout;
  }

  get psLayout(): IPSLayout | null {
    return this.getPSLayout();
  }

  getPSLayoutMust(): IPSLayout {
    const value = this.getPSLayout();
    if (value == null) {
      throw new Error('未指定布局设置');
    }
    return value;
  }

  protected pslayoutpos: IPSLayoutPos | null = null;

  getPSLayoutPos(): IPSLayoutPos | null {
    if (this.pslayoutpos != null) return this.pslayoutpos;
    const value = this.M.getPSLayoutPos;
    if (value == null) {
      return null;
    }
    this.pslayoutpos = this.getPSModel4('control.layout.IPSLayoutPos', value, 'getPSLayoutPos') as IPSLayoutPos;
    return this.pslayoutpos;
  }

  get psLayoutPos(): IPSLayoutPos | null {
    return this.getPSLayoutPos();
  }

  getPSLayoutPosMust(): IPSLayoutPos {
    const value = this.getPSLayoutPos();
    if (value == null) {
      throw new Error('未指定布局位置');
    }
    return value;
  }

  protected pssyscss: IPSSysCss | null = null;

  getPSSysCss(): IPSSysCss | null {
    if (this.pssyscss != null) return this.pssyscss;
    const value = this.M.getPSSysCss;
    if (value == null) {
      return null;
    }
    this.pssyscss = this.getPSModel4('res.IPSSysCss', value, 'getPSSysCss') as IPSSysCss;
    return this.pssyscss;
  }

  get psSysCss(): IPSSysCss | null {
    return this.getPSSysCss();
  }

  getPSSysCssMust(): IPSSysCss {
    const value = this.getPSSysCss();
    if (value == null) {
      throw new Error('未指定成员样式表');
    }
    return value;
  }

  protected pssysimage: IPSSysImage | null = null;

  getPSSysImage(): IPSSysImage | null {
    if (this.pssysimage != null) return this.pssysimage;
    const value = this.M.getPSSysImage;
    if (value == null) {
      return null;
    }
    this.pssysimage = this.getPSModel4('res.IPSSysImage', value, 'getPSSysImage') as IPSSysImage;
    return this.pssysimage;
  }

  get psSysImage(): IPSSysImage | null {
    return this.getPSSysImage();
  }

  getPSSysImageMust(): IPSSysImage {
    const value = this.getPSSysImage();
    if (value == null) {
      throw new Error('未指定成员图标');
    }
    return value;
  }

  protected pssyspfplugin: IPSSysPFPlugin | null = null;

  getPSSysPFPlugin(): IPSSysPFPlugin | null {
    if (this.pssyspfplugin != null) return this.pssyspfplugin;
    const value = this.M.getPSSysPFPlugin;
    if (value == null) {
      return null;
    }
    this.pssyspfplugin = this.getPSModel4('res.IPSSysPFPlugin', value, 'getPSSysPFPlugin') as IPSSysPFPlugin;
    return this.pssyspfplugin;
  }

  get psSysPFPlugin(): IPSSysPFPlugin | null {
    return this.getPSSysPFPlugin();
  }

  getPSSysPFPluginMust(): IPSSysPFPlugin {
    const value = this.getPSSysPFPlugin();
    if (value == null) {
      throw new Error('未指定前端扩展插件');
    }
    return value;
  }

  protected showmoremgrpsdeformdetail: IPSDEFormDetail | null = null;

  getShowMoreMgrPSDEFormDetail(): IPSDEFormDetail | null {
    if (this.showmoremgrpsdeformdetail != null) return this.showmoremgrpsdeformdetail;
    const value = this.M.getShowMoreMgrPSDEFormDetail;
    if (value == null) {
      return null;
    }
    this.showmoremgrpsdeformdetail = this.getPSModel4('control.form.IPSDEFormDetail', value, 'getShowMoreMgrPSDEFormDetail') as IPSDEFormDetail;
    return this.showmoremgrpsdeformdetail;
  }

  get showMoreMgrPSDEFormDetail(): IPSDEFormDetail | null {
    return this.getShowMoreMgrPSDEFormDetail();
  }

  getShowMoreMgrPSDEFormDetailMust(): IPSDEFormDetail {
    const value = this.getShowMoreMgrPSDEFormDetail();
    if (value == null) {
      throw new Error('未指定显示更多管理者');
    }
    return value;
  }

  get showMoreMode(): 0 | 1 | 2 {
    return this.M.showMoreMode != null ? this.M.showMoreMode : 0;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get width(): number {
    return this.M.width != null ? this.M.width : 0.0;
  }

  get repeatContent(): boolean {
    return this.M.repeatContent != null ? this.M.repeatContent : false;
  }

  get showCaption(): boolean {
    return this.M.showCaption;
  }

  get cls(): string {
    return 'PSDEFormDetailImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'control.IPSControlItem' || cls == 'control.form.IPSDEFormDetail' || cls == 'control.layout.IPSLayoutItem') return true;
    return super.instanceof(cls);
  }
}
